package model;

import java.util.Collection;

import java.util.Vector;


import javax.swing.table.AbstractTableModel;


public class PrepayTableModel extends AbstractTableModel {


	/**
	 * 
	 */
	private static final long serialVersionUID = -4261499749807184138L;

	private Vector records = new Vector();
	   
	   private String[] columnNames = {"tradeNo","ID","tradeDate","amount","tradeType"};
	   public PrepayTableModel(){
	   
	   }
	   
	    public int getRowCount() {    
	        return this.records.size();
	    }
	    public int getColumnCount() {  
	        return this.columnNames.length;
	    }
	    public String getColumnName(int column) {
			return this.columnNames[column];
		}	 
	    public Object getValueAt(int row, int col) {       
	    	PrepayRecordItem record =(PrepayRecordItem) records.get(row);
			switch (col){
				case 0 :return record.getSerialNo();
				case 1 :return record.getCardNo();
				case 2 :return record.getDate();
				case 3 :return record.getMoney();
				case 4 :return record.getMark();			
			}
			return null;
	    }
		public boolean isCellEditable(int rowIndex, int columnIndex){
		    return false;
		}
		public Class<?> getColumnClass(int columnIndex) { // 得到指定列的类型
			   return this.getValueAt(0,columnIndex).getClass() ;
			}
        //初始化table中的数据
		public void addAllRecords(Collection all){
			 records.clear();
		        if(all != null)
		    	records.addAll(all);
		        this.fireTableDataChanged();
		    
		}
	

}
